<template>
  <div class="box">
    <div class="nav" v-if="!$store.state.isLogin" @click="$router.push('/login')">
      <img class="nav-icon" src="../assets/usericon.png" alt="">
      <div class="nav-title">立即登录</div>
    </div>
    <div class="nav" v-else>
      <img class="nav-icon" src="../assets/loginuser.jpg" alt="">
      <div class="nav-title">188****8888</div>
    </div>

    <ul class="my-order-tab">
      <li @click="functionClick">
        <img src="../assets/movedetail.png" alt="">
        <div class="common-p">电影订单</div>
      </li>
      <li @click="functionClick">
        <img src="../assets/goodsdetail.png" alt="">
        <div class="common-p">商品订单</div>
      </li>
    </ul>

    <div class="margin-set" @click="functionClick">
      <img class="icon" src="../assets/mzquan.png" alt="">
      <span class="label">卖座券</span>
      <img class="arrow" src="../assets/arrowright.png" alt="">
    </div>
    <div class="margin-set" @click="functionClick">
      <img class="icon" src="../assets/redpacket.png" alt="">
      <span class="label">组合红包</span>
      <img class="arrow" src="../assets/arrowright.png" alt="">
    </div>
    <div class="margin-set" @click="functionClick">
      <img class="icon" src="../assets/wallet.png" alt="">
      <span class="label">余额</span>
      <img class="arrow" src="../assets/arrowright.png" alt="">
    </div>
    <div class="margin-set" @click="functionClick">
      <img class="icon" src="../assets/set.png" alt="">
      <span class="label">设置</span>
      <img class="arrow" src="../assets/arrowright.png" alt="">
    </div>
    <div class="margin-set" v-if="$store.state.isLogin" @click="outLogin">
      <span class="label">退出登录</span>
      <img class="arrow" src="../assets/arrowright.png" alt="">
    </div>
  </div>
</template>

<script>
export default {
  name: 'Center',
  methods: {
    functionClick() {
      if (this.$store.state.isLogin) {
        this.$toast('此功能暂未开放')
      } else {
        this.$router.push('/login')
      }
    },
    outLogin() {
      this.$dialog
        .confirm({
          title: "退出账号确认",
          message: "您是否想要退出当前账号？",
          confirmButtonColor: '#ff5f16'
        })
        .then(() => {
          // 改变当前登陆状态
          this.$store.commit('changeLogin', false)
          this.$toast('退出成功')
          // 刷新当前页面
          this.$router.go(0)
      }).catch(err => err)
    }
  }
}
</script>

<style scoped>
.box {
  background: #f4f4f4;
}
.nav {
  text-align: center;
  margin-top: -.44rem;
  height: 2.00rem;
  padding-left: .22rem;
  padding-top: .64rem;
  background: url(../assets/userback.png);
  background-size: cover;
  display: flex;
  align-items: center;
  color: #fff;
  box-sizing: border-box;
}
.nav img {
  width: .63rem;
  height: .63rem;
  border-radius: 35px;
  margin-right: .20rem;
  border: 2px solid #fff;
}
.nav .nav-title {
  font-size: .16rem;
}





.my-order-tab {
  width: 100%;
  margin: 0 auto;
  display: flex;
  text-align: center;
  font-size: .13rem;
  padding: 0;
  height: .79rem;
  background: #fff;
  margin-bottom: .10rem;
  align-items: center;
}
.my-order-tab li {
  position: relative;
  flex: 1;
  margin: 0;
  padding: 0;
}
.my-order-tab li img {
  width: .26rem;
  height: .26rem;
}
.my-order-tab li .common-p {
  margin-top: .05rem;
  color: #797d82;
}





.margin-set {
  background: #fff;
  padding: 0 15px;
  height: 49px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f4f4f4;
}
.margin-set .icon {
  width: 20px;
  height: 20px;
}
.margin-set .label {
  margin-left: 15px;
  color: #191a1b;
  font-size: .15rem;
  flex: 1;
}
.margin-set .arrow {
  text-align: right;
  width: 6px;
  height: 10px;
}
</style>